<!DOCTYPE html>
<html>
	<head>
		<title>Loading with data aggregation</title>
		<link rel="stylesheet" href="../../../codebase/webix.css" type="text/css" charset="utf-8">
		<script src="../../../codebase/webix.js" type="text/javascript" charset="utf-8"></script>

		<link rel="stylesheet" type="text/css" href="../common/samples.css">
		<script src="../common/testdata.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div class='sample_comment'>Original</div>
		<div id="testA"></div>
		<hr>
		<div class='sample_comment'>Aggregated data</div>
		<div id="testB"></div>

		<script type="text/javascript" charset="utf-8">

		webix.ready(function(){
			var myformat = webix.i18n.numberFormat;

			grida = new webix.ui({
				container:"testA",
				view:"datatable",
				columns:[
					{ id:"rank",	header:"", css:"rank",  		width:50},
					{ id:"title",	header:"Film title",width:200},
					{ id:"year",	header:"Released" , width:80},
					{ id:"votes",	header:"Votes", 	width:100}
				],
				autowidth:true,
				height:300,

				data: big_film_set
			});	
			

			gridb = new webix.ui({
				container:"testB",
				view:"datatable",
				columns:[
					{ id:"year",		header:"Released" , width:100},
					{ id:"votes_sum",	header:"Total Votes", 	format:myformat, width:110},
					{ id:"votes_max",	header:"Max Votes", 	format:myformat, width:110},
					{ id:"votes_min",	header:"Min Votes", 	format:myformat, width:110}
				],
				height:300,
				autowidth:true,

				scheme:{
					$group:{
						by:"year",
						map:{
							"year"     :["year",  "any"],
							"votes_sum":["votes", "sum"],
							"votes_min":["votes", "min"],
							"votes_max":["votes", "max"]
						}
					},
					$sort:"year"
				},

				data:big_film_set
			});	
							
		});
		</script>
	</body>
</html>